﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Pool
{
    private List<Resource> resources;

    public Pool()
    {
        resources = new List<Resource>();
    }

    internal List<Resource> Resources
    {
        get { return resources; }
    }  
    
    public Resource GetResource()
    {
        for (int i = 0; i < this.resources.Count; i++)
        {
            if (this.resources[i].Available == true)
            {
                this.resources[i].Available = false;
                return this.resources[i];
            }
        }
        Resource newResource = new Resource(this.resources.Count + 1);
        newResource.Available = false;
        this.resources.Add(newResource);
        return newResource;
    }    
}
